<template>
    <div>
      <el-table v-loading="loading" :data="list" >
        <el-table-column label="保险单号" align="center" prop="insuranceOdd" />
        <el-table-column label="保险名称" align="center" prop="insuranceName" />
        <el-table-column label="保险额度" align="center" prop="insuranceQuato" />
        <el-table-column label="开始时间" align="center" prop="startTime" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="结束时间" align="center" prop="endTime" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="保险预警" align="center">
          <template slot-scope="scope">
            <span>{{ timeDifference(scope.row.endTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="在保人数" align="center" prop="insuranceNumber" />
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button size="mini" type="text" @click="handleSelected(scope.row)">选择</el-button>
            </template>
          </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList" />
    </div>
  </template>

  <script>
  import { listInsurance } from "@/api/cld/insurance";
  export default {
    name: "selectedInsurance",
    props: {

    },
    data() {
      return {
        // 遮罩层
        loading: true,
        list: [],
        total: 0,
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          insuranceStatus: 1,
        },
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询资产信息列表 */
      getList() {
        this.loading = true;
        listInsurance(this.queryParams).then(response => {
          this.list = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 选择保险
      handleSelected(e) {
        this.$emit('childInput', e);
      },
    }
  };
  </script>
